home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 38 / Amiga Format CD38 (1999-03-15)(Future Publishing)(GB)(Track 1 of 3)[!][issue 1999-04].iso / -seriously_amiga- / programming / other / cyberxxxsrc / misc / intel2mot.asm < prev    next >
Assembly Source File  |  1999-02-08  |  1KB  |  85 lines

  1. ;prog:phxass/gigaphxass asm/Intel2Mot.asm to obj/Intel2Mot.o noexe
  2.  
  3.     SECTION Intel,CODE
  4.  
  5.     XDEF    _LSB2MSBLong
  6.  
  7. ; ulong LSB2MSBLong(unsigned long x)
  8. ; {
  9. ;   return (x & 0xff000000) >> 24 | (x & 0x00ff0000) >> 8 | (x & 0x0000ff00) << 8 | (x & 0x000000ff) << 24;
  10. ; }
  11.  
  12. _LSB2MSBLong:
  13.     moveq   #8,d1
  14.     rol.w   d1,d0
  15.     swap    d0
  16.     rol.w   d1,d0
  17.  
  18.     rts
  19.  
  20.     XDEF    _LSB2MSBShort
  21.  
  22. _LSB2MSBShort:
  23.     rol.w   #8,d0
  24.     and.l   #$0000ffff,d0
  25.     rts
  26.  
  27.  
  28.  
  29.     XDEF    _ByteTo32
  30.  
  31. ; ulong ByteTo32(unsigned char x)
  32. ; {
  33. ;   ulong t;
  34. ;   t=x<<8 | x;
  35. ;   return t << 16 | t;
  36. ; }
  37.  
  38. _ByteTo32:
  39.     and.l   #$000000ff,d0
  40.     move.l  d0,d1
  41.     asl.l   #8,d1
  42.     or.l    d0,d1
  43.     move.l  d1,d0
  44.     swap    d0
  45.     clr.w   d0
  46.     or.l    d1,d0
  47.     rts
  48.  
  49.  
  50.  
  51.     XDEF    _ShortTo32
  52.  
  53. ; ulong ShortTo32(ushort x)
  54. ; {
  55. ;   ulong t;
  56. ;   t=x<<16 | x;
  57. ;   return t << 16 | t;
  58. ; }
  59.  
  60. _ShortTo32:
  61.     and.l   #$0000ffff,d0
  62.     move.l  d0,d1
  63.     swap    d0
  64.     clr.w   d0
  65.     or.l    d1,d0
  66.     rts
  67.  
  68.  
  69.  
  70.     XDEF    _Round
  71.  
  72. ; ulong Round(ulong x, ulong r)
  73. ; {
  74. ;   return ((x+r-1)*r)/r;
  75. ; }
  76.  
  77. _Round:
  78.     add.l   d1,d0
  79.     subq.l  #1,d0
  80.     divu.l  d1,d0
  81.     mulu.l  d1,d0
  82.     rts
  83.  
  84.     END
  85.